<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>利用 a 标签解析 URL.html</title>
</head>
<body>
	
</body>
<script>
	function parseURL(url) {	
    var a =  document.createElement('a');	
    a.href = url;	
    return {	
        host: a.hostname,	
        port: a.port,	
        query: a.search,	
        params: (function(){	
            var ret = {},	
                seg = a.search.replace(/^\?/,'').split('&amp;'),	
                len = seg.length, i = 0, s;	
            for (;i&lt;len;i++) {	
                if (!seg[i]) { continue; }	
                s = seg[i].split('=');	
                ret[s[0]] = s[1];	
            }	
            return ret;	
        })(),	
        hash: a.hash.replace('#','')	
    };	
}
</script>
</html>